package common
{

    import common.message.MiddleMessage;
    import common.message.PublicNotice;
    
    import flash.display.Sprite;
    import flash.net.LocalConnection;
    import flash.utils.flash_proxy;
    
    import kernel.application.ApplicationDisplay;
    import kernel.core.AllObjects;
    import kernel.core.ClientDataCatch;
    import kernel.core.Core;
    import kernel.filter.WordFilter;
    import kernel.server.HttpServer;
    
    import models.PlayerModel;
    
    import modulesInterface.IChat;
    import modulesInterface.IMap;
    import modulesInterface.IMapMedia;

    public class API
    {
		/**
		 * 地图访问口 
		 */
		public static var iChat:IChat;
		public static var iMap:IMap;
		public static var iMapMedia:IMapMedia;
		public static var uploadHttpServer:HttpServer;

        private static const _socketCodeState:Object = {};

        private static var _isLocal:Boolean = false;
		
		
		public static function get playerModel():PlayerModel
		{
			return Core.getFromDataCatch(PlayerModel) as PlayerModel;
			
			
		}


        public static function filterText(text:String):String
        {
            if (WordFilter.filterFunction != null)
            {
                return WordFilter.filterFunction (text);
            }
            var a:Object = WordFilter;
            return text;
        }

        public static function isInFilter(text:String):Boolean
        {
            if (WordFilter.checkIsFilter != null)
            {
                return Boolean (WordFilter.checkIsFilter (text));
            }
            return false;
        }

        public static function setSocketState(code:String):void
        {
            _socketCodeState[code] = true;
        }

        public static function checkIsSocketGeted(code:String):Boolean
        {
            if (_socketCodeState[code] == true)
                return true;
            return false;
        }

        public static function checkIsSocketGetedUint(code:uint):Boolean
        {
            return checkIsSocketGeted (code.toString ());
        }



        /**
         * 创建立即显示一个屏幕中央提示信息
         * @param message 文本，可以为html文本
         * @param showTime 要显示的时间
         * @param color
         * @param size
         * @return
         *
         */
        public static function showMiddleMessage(message:String , showTime:uint = 3000 , color:uint = 0xFFE066 , size:uint = 16):MiddleMessage
        {
            var mid:MiddleMessage = new MiddleMessage (message , showTime , color , size);
            return mid;
        }


        /**
         * 将一个消息添加到行为公告区
         * @param message html消息文本
         *
         */
        public static function addPublicNotice(message:String , color:uint = 0xFFFFFF):void
        {
            PublicNotice.instance.add (message , color);
        }



    }
}
